import java.util.ArrayList;
import java.util.List;

public class Solution1408 {
    public List<String> stringMatching(String[] words) {
        List<String> ans=new ArrayList<>();
        for (String word : words) {
            for (String s : words) {
                if (s.contains(word) && !s.equals(word)){
                    ans.add(word);
                    break;
                }
            }
        }
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1408().stringMatching(new String[]{"mass","as","hero","superhero"}));
    }
}
